#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <pthread.h>
#include <fcntl.h>
#include <limits.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <malloc.h>
#include <time.h>


#define count_thr_num 5
#define req_thr_num 5
#define req_job_num 20

#define count_thr_max_num 20
#define queue_job_max 10

typedef struct job{
    struct job *next;
		int a;
		int b;
		int operate;
    int result;
}jobq, *pjob;

typedef struct queue{
	  struct job *q_head;
		struct job *q_tail;
		int job_num;
		int job_max;
		pthread_mutex_t q_lock;
}workq, *pwork;

typedef struct threadpool{
	  int cur_count_thr_num;
		int pool_close;
		pthread_mutex_t t_lock;
}*pthr;



//use the workque to save calculate resquest
struct queue workque[count_thr_max_num];

//use the result to save calculate result
struct queue resultque;

//this is threadpool
struct threadpool thrpool;

//thread to calculate signal
pthread_cond_t qready_calculate[count_thr_max_num];

//create thread signal
pthread_cond_t qready_create_thr;

int pthread_num[count_thr_max_num];

//the total number od the job
int count = req_thr_num*req_job_num;
